LGF_Integration (FB / 3.1.0)

Overview

Author: Siemens Digital Industries

Short description

The function approximately calculates the area under a function curve (the integral). The function curve is transferred as an analog value (LReal) which varies over time. The integral value is output on integral.
The implementation is based on the trapezoidal rule and uses second [s] as time base, e.g. speed [m/s].

Block Interface

LGF_Integration (FB)
Bool  enable integral  LReal
    
LReal  value error  Bool
    
Bool  reset status  Word
    
   subfunctionStatus  Word
    
   

Input parameter

IdentifierData type Default value Description
enableBool FALSE Enables integral calculation
If this input is set to the value `FALSE`, the integral calculation is stopped and the `integral` output shows the last calculated value.
valueLReal 0.0 Analog value of the continuous function curve, based on [s], (e.g. [volume flow/s])
resetBool FALSE Sets the output “integral” to “0.0”.

Output parameter

IdentifierData type Description
integralLReal Integral value
errorBool FALSE: No error
TRUE: An error occurred during the execution of the FB
statusWord 16#0000-16#7FFF: Status of the FB
16#8000-16#FFFF: Error identification (see following Table)
subfunctionStatusWord Status or return value of called FB's, FC's and system blocks

Status & Error codes

Code / ValueIdentifier / Description
16#0000STATUS_EXECUTION_FINISHED_NO_ERROR
Status: No error in the function during execution
16#8600ERR_READ_SYS_TIME
Error: System time FC `RD_SYS_T` returned an error when excuting - check `subFunctionStatus` code

Functional description

NOTE
The status of called commands is output in subFunctionStatus. In this case, the output value in status indicates which command caused the error. In this case, refer to the TIA Portal Online Help section for information on the respective commands.

The integral calculation includes the summation of those trapezoidal areas that span between the last two function values on the value input and the time. The elapsed time is calculated via the system time of the CPU. This trapezoidal area is identical to the product of the mean value of the two process values and the time interval.


NOTE
The calculation takes [s] as time base. So the analoge value hase to use the same time base, e.g. speed [m/s].

A = \frac{1}{2} * (F_{t_1}+F_{t_0}) * (t_1-t_0) + \frac{1}{2} * (F_{t_2}+F_{t_1}) * (t_2-t_1) + ...

Figure: Principle of operation

LGF_Integration - Principle of operation

Start the integral calculation for the inputvalue at the parameter value:

If the parameter enable is set to the value FALSE, the integral calculation is stopped and the output integral outputs the last calculated value.
If the parameter reset is set to the value TRUE, the output integral is reset to 0.0

Change log

Version & DateChange description
1.0.0Siemens Industry Online Support
17.02.2017First released version
1.0.1Siemens Industry Online Support
17.08.2018Upgrade: TIA V15 Update 2
1.0.2Siemens Industry Online Support
23.11.2018Upgrade: TIA V15.1
1.1.0Simatic Systems Support
12.11.2019Regions, comments and constants are added, code refactored
3.0.0Simatic Systems Support
23.04.2020Set version to V3.0.0, harmonize the version of the whole library
3.0.1Simatic Systems Support
09.02.2021Insert documentation
3.0.2Simatic Systems Support
07.06.2021Fix bug - incompatibility with S7-1200 and LTIME
3.1.0Simatic Systems Support
11.07.2025Fix bug - Time measurement and calculation for nanoseconds fixed
Fix Wording/Bug - Time measurement scaling [ms] / [s] - timing for calculatiuon is bnased on seconds